﻿using FishSimulation.Model;
using System.Collections.Generic;
using System.Linq;

namespace FishSimulation.Views
{
    /// <summary>
    /// Interaction logic for ActorTypeMenuView.xaml
    /// </summary>
    public partial class ActorTypeMenuView : ViewBase
    {        
        public ActorTypeMenuView()
        {
            InitializeComponent();
        }

        public void Bind(IEnumerable<ActorType> at) {
            this.DataContext = at;
            var all_types = Repository.Instance.GetActorTypes();
            foreach (ActorType t in all_types) {
                if(at.Contains(t))
                    t.IsChecked = true;
            }
            box.ItemsSource = all_types;
        }

        public IEnumerable<ActorType> GetCheckedItems() {
            return (box.ItemsSource as IEnumerable<ActorType>).Where(x => x.IsChecked);
        }
    }
}
